﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>流程字段列表</title>
    <meta charset="UTF-8" />
    <script type="text/javascript" src="../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="../../Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../Comm/Gener.js" type="text/javascript"></script>
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <base target="_self" />
    <script language="javascript" type="text/javascript">
        /* ESC Key Down */
        function Esc() {
            if (event.keyCode == 27)
                window.close();
            return true;
        }
        function WinOpen(url, name) {
            window.open(url, name, 'height=600, width=800, top=0, left=0, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no');
            //window.open(url, 'xx');
        }
        function TROver(ctrl) {
            ctrl.style.backgroundColor = 'LightSteelBlue';
        }

        function TROut(ctrl) {
            ctrl.style.backgroundColor = 'white';
        }
        function ShowHidden(ctrlID) {

            var ctrl = document.getElementById(ctrlID);
            if (ctrl.style.display == "block") {
                ctrl.style.display = 'none';
            } else {
                ctrl.style.display = 'block';
            }
        }
        //页面启动函数.
        $(function () {

            $("#Msg").html("<img src=../../Img/loading.gif />&nbsp;正在加载,请稍后......");

            InitPage();

            $("#Msg").html("");
        });
        var userId;
        //初始化数据.
        function InitPage() {

            var fk_flow = GetQueryString("FK_Flow");

            var data = new Entity("BP.WF.Flow", fk_flow);

            GenerFullAllCtrlsVal(data);

            var nodeID = fk_flow + "01";

            var fns = new Entities("BP.WF.Template.FrmNodes");
            fns.Retrieve("FK_Node", nodeID);

            if (fns.length > 2) {
                $("#isShow").show();
                $('#RB_StartGuideWay_90').attr('checked', 'true');
            } else {
                $("#isShow").hide();
                $('#RB_StartGuideWay_90').removeAttr('checked');
            }

            GenerFullAllCtrlsVal(data);

            //右侧连接.
            $("#TB_GuideLink").val(data.StartGuideLink);
            $("#TB_GuideLab").val(data.StartGuideLab);


            //查询出来数据.
            var parts = new Entities("BP.WF.Template.Parts");
            parts.Retrieve("PartType", "ParentSubFlowGuide", "FK_Flow", fk_flow);

            var strs = "<table>";
            strs += "<tr>";
            strs += "<th>流程编号</th>";
            strs += "<th>名称</th>";
            strs += "<th>操作</th>";
            strs += "</tr>";

            for (var i = 0; i < parts.length; i++) {
                var part = parts[i];

                strs += "<tr>";
                strs += "<td>" + part.Tag0 + "</td>";
                strs += "<td>" + part.Tag1 + "</td>";
                strs += "<td><a href=\"javascript:Part('"+part.MyPK+"');\" >编辑</a></td>";
                strs += "</tr>";
            }
            strs += "</table>";

            $("#parts").val(strs);

            //alert(data.StartGuideWay);

            //console.info(data.StartGuidePara1)
            switch (data.StartGuideWay) {
                case '0': //无
                    //this.RB_None.Checked = true;
                    break;
                case '5': //从开始节点Copy数据
                    $("#TB_ByHistoryUrl").val(data.StartGuidePara1);
                    break;
                case '10': //按自定义的Url
                    //console.info(data.StartGuidePara1);
                    $("#TB_SelfURL").val(data.StartGuidePara1);
                    break;
                case '1': //按照参数.
                    $("#TB_BySQLOne1").val(data.StartGuidePara1);
                    $("#TB_BySQLOne2").val(data.StartGuidePara2);
                    $("#TB_BySQLOne3").val(data.StartGuidePara3);
                    break;
                case '6': //SQL多条模式
                    $("#TB_BySQLMulti1").val(data.StartGuidePara1);
                    $("#TB_BySQLMulti2").val(data.StartGuidePara2);
                    $("#TB_BySQLMulti3").val(data.StartGuidePara3);

                    break;
                case '3':
                    break;
                case '4': //子父流程多条模式- 合卷审批.
                    $("#TB_SubFlow1").val(data.StartGuidePara1);
                    $("#TB_SubFlow2").val(data.StartGuidePara2);
                    break;
                case '11':
//                    var ens = new Entities("");
//                    $("#parts").val(data.StartGuidePara2);
                    break;
                default:
                    break;
            }
            return;
        }

        function NewPart() {

        }

        function SaveEn() {

            //指定实体对象,并进行实例化
            var fk_flow = GetQueryString("FK_Flow");
            var data = new Entity("BP.WF.Flow", fk_flow);

            //取得前台所设置的前置导航类型和值
            inputObj = $("input[name='RB_StartGuideWay']:checked");
            seleID = inputObj.attr('id');
            seleVal = inputObj.val();
            data.StartGuideWay = seleVal;


            //根据类型值取出对应的div中的子节点textarea的值,并将值赋值给实体对象
            div = "div[name='" + seleID + "']"
            var allChildTA = $(div + " textarea");
            jQuery.each(allChildTA, function (i, field) {

                if (i == 0) {
                    data.StartGuidePara1 = field.value;
                }

                if (i == 1) {
                    data.StartGuidePara2 = field.value;
                }

//                if (i == 2) {
//                    data.StartGuidePara3 = $("#TB_BySQLOne3").val();
//                }
            });

            data.StartGuidePara3 = $("#TB_BySQLOne3").val();


            //右侧连接.
            guideLink = $("#TB_GuideLink").val();
            data.StartGuideLink = guideLink;
            guideLab = $("#TB_GuideLab").val();
            data.StartGuideLab = guideLab;

            data.Update();
            alert("保存成功");
            window.location.href = window.location.href;
        }
        function Help() {
            var url = "http://ccbpm.mydoc.io";
            window.open(url);
        }
        
    </script>
</head>
<body>
    <form action="" id="form1">
    <table style="width: 98%">
        <caption>
            发起前置导航</caption>
        <tr>
            <!--<td valign="top" style="width: 20%;">
                <fieldset>
                    <legend>帮助</legend>

                    <ul>
                        <li>我们经常会遇到用户发起流程前，首先进入一个实体列表界面（比如项目列表，成员列表、供应商列表。），选择一个实体后把该实体的信息带入开始节点的表单字段里，我们把这个应用场景叫做发起前置导航方式。发起前置导航方式有如下几种应用场景，开发者根据需要进行配置。</li>
                        <p />
                        <li>比如：流程发起前，先列出所有纳税人列表，用户选中一条，会将纳税人信息直接填充到表单内。</li>

                    </ul>
                </fieldset>
            </td>-->
            <td valign="top">
                <fieldset>
                    <legend>
                        <input id="RB_StartGuideWay_0" type="radio" name="RB_StartGuideWay" value="0" /><label
                            for="RB_StartGuideWay_0">无（默认）</label>
                    </legend><font color="gray">不设置任何前置导航，发起流程直接进入开始节点表单。</font>
                </fieldset>
                <fieldset>
                    <legend>
                        <input id="RB_StartGuideWay_5" type="radio" name="RB_StartGuideWay" value="5" /><label
                            for="RB_StartGuideWay_5">从历史发起的流程Copy数据(查询历史记录)</label>
                    </legend><a href="javascript:ShowHidden('ByHistoryUrl')">请设置SQL</a>:
                    <div id="ByHistoryUrl" style="display: none; color: gray">
                        <ul>
                            <li>用户希望出现一个历史发起的流程列表，选择一条流程并把该流程的数据copy到新建的流程上。</li>
                            <li>您需要在这里配置一个SQL, 并且该SQL必须有一个OID列。</li>
                            <li>比如：SELECT Title ,OID FROM WF_GenerWorkFlow WHERE Title LIKE '%@Key%' AND FK_Flow='001'
                                AND WFState=3 </li>
                        </ul>
                    </div>
                    <!--<input type="text" value="" id="TB_ByHistoryUrl" name="TB_ByHistoryUrl" style="width:98%; height: 24px" />-->
                    <div name="RB_StartGuideWay_5">
                        <textarea id="TB_ByHistoryUrl" name="TB_ByHistoryUrl" runat="server" style="width: 98%;
                            height: 24px"></textarea>
                        <br />
                    </div>
                </fieldset>

                <!--自定义url模式  -->
                <fieldset>
                    <legend>
                        <input id="RB_StartGuideWay_10" type="radio" name="RB_StartGuideWay" value="10" /><label
                            for="RB_StartGuideWay_10">按自定义的Url</label>
                    </legend><a href="javascript:ShowHidden('ByUrl')">请设置URL:</a>
                    <div id="ByUrl" style="display: none; color: gray">
                        <ul>
                            <li>请设置URL在下面的文本框里。</li>
                            <li>该URL是一个列表，在每一行的数据里有一个连接链接到工作处理器上（/WF/MyFlow.htm）</li>
                            <li>连接到工作处理器（ WF/MyFlow.htm）必须有2个参数FK_Flow=xxx&IsCheckGuide=1</li>
                            <li>您可以打开Demo: /SDKFlowDemo/TestCase/StartGuideSelfUrl.htm 详细的说明了该功能如何开发。</li>
                        </ul>
                    </div>
                    <div name="RB_StartGuideWay_10">
                        <!-- <input type="text" id="TB_SelfURL" name="TB_SelfURL" runat="server" style="width:98%; height: 24px"/>-->
                        <textarea id="TB_SelfURL" name="TB_SelfURL" runat="server" style="width: 98%; height: 24px"></textarea><br />
                    </div>
                </fieldset>

                <!--父子流程模式  -->
                <fieldset>
                    <legend>
                        <input id="RB_StartGuideWay_12" type="radio" name="RB_StartGuideWay" value="12" /><label
                            for="RB_StartGuideWay_12">父子流程模式</label>   - <a href="javascript:NewPart();" >新建</a> - <a href="javascript:ShowHidden('ByFPlow')">帮助</a>
                    </legend>
                    <div id="ByFPlow" style="display: none; color: gray">
                        <ul>
                            <li>请设置URL在下面的文本框里。</li>
                            <li>该URL是一个列表，在每一行的数据里有一个连接链接到工作处理器上（/WF/MyFlow.htm）</li>
                            <li>连接到工作处理器（ WF/MyFlow.htm）必须有2个参数FK_Flow=xxx&IsCheckGuide=1</li>
                            <li>您可以打开Demo: /SDKFlowDemo/TestCase/StartGuideSelfUrl.htm 详细的说明了该功能如何开发。</li>
                        </ul>
                    </div>
                    <div id="parts" >无设置，请点击新建。</div>
                </fieldset>

                <!--按设置的SQL-单条模式  -->
                <fieldset>
                    <legend>
                        <input id="RB_StartGuideWay_1" type="radio" name="RB_StartGuideWay" value="1" /><label
                            for="RB_StartGuideWay_1">按设置的SQL-单条模式</label> - <a href="http://ccbpm.mydoc.io/?v=5404&t=340507" target=_blank ><img src='../../Img/Help.gif'>帮助</a>
                    </legend><a href="javascript:ShowHidden('Paras1')">查询参数:</a>
                    <div id="Paras1" style="display: none; color: gray">
                        <ul>
                            <li>比如:SELECT No, Name, No as EmpNo,Name as EmpName,Email FROM WF_Emp WHERE No LIKE
                                '%@key%' </li>
                            <li>初始化列表参数，该查询语句必须有No,Name两个列，注意显示数量限制。</li>
                            <li>很多场合下需要用到父子流程，在启动子流程的时候需要选择一个父流程。</li>
                            <li>实例:SELECT a.WorkID as No, a.Title as Name, a.Starter, a.WorkID As PWorkID, '011'
                                as PFlowNo, a.FK_Node as PNodeID FROM WF_GenerWorkflow a, WF_GenerWorkerlist b WHERE
                                A.WorkID=b.WorkID AND B.FK_Emp='@WebUser.No' AND B.IsPass=0 AND A.FK_Flow='011'
                                AND a.Title Like '%@Key%'</li>
                        </ul>
                    </div>
                    <!--<input type="text" id="TB_BySQLOne1" name="TB_BySQLOne1" rows="3"  runat="server" style="width:98%; height: 51px"/>-->
                    <div name="RB_StartGuideWay_1">
                        <textarea id="TB_BySQLOne1" name="TB_BySQLOne1" rows="3" style="width: 98%; height: 51px"></textarea>
                        <br />
                        <a href="javascript:ShowHidden('ByParas2')">初始化列表参数:</a>
                        <div id="ByParas2" style="display: none; color: gray">
                            <ul>
                                <li>比如:SELECT top 15 No,Name ,No as EmpNo,Name as EmpName ,Email FROM WF_Emp </li>
                                <li>或者:SELECT No,Name ,No as EmpNo,Name as EmpName ,Email FROM WF_Emp WHERE ROWID <
                                    15 </li>
                                <li>该数据源必须有No,Name两个列, 其他的列要与开始节点表单字段对应。</li>
                                <li>注意查询的数量，避免太多影响效率。</li>
                            </ul>
                        </div>
                        <textarea id="TB_BySQLOne2" name="TB_BySQLOne2" rows="3" runat="server" style="width: 98%;
                            height: 51px"></textarea>
                    </div>
                    <div>
                        <a href="javascript:ShowHidden('ByParas3')">装载一行的数据SQL:</a>
                        <div id="ByParas3" style="display: none; color: gray">
                            <ul>
                                <li>比如:SELECT No as EmpNo,Name as EmpName ,Email FROM WF_Emp WHERE No='@Key' </li>
                                <li>该数据源返回的列名大小写与开始节点表单的字段名匹配， 只有匹配成功的才能赋值.</li>
                            </ul>
                        </div>
                        <textarea id="TB_BySQLOne3" name="TB_BySQLOne3" rows="3" style="width: 98%; height: 51px"></textarea>
                        <br />
                    </div>
                </fieldset>
                <fieldset>
                    <legend>
                        <input id="RB_StartGuideWay_6" type="radio" name="RB_StartGuideWay" value="6" /><label
                            for="RB_StartGuideWay_6">按设置的SQL-多条模式(用于批量发起)</label>
                    </legend><a href="javascript:ShowHidden('ParasMulti1')">查询参数:</a>
                    <div id="ParasMulti1" style="display: none; color: gray">
                        <ul>
                            <li>比如:SELECT No, Name, No as EmpNo,Name as EmpName,Email FROM WF_Emp WHERE No LIKE
                                '%@key%' </li>
                            <li>初始化列表参数，该查询语句必须有No,Name两个列，注意显示数量限制。</li>
                            <li>很多场合下需要用到父子流程，在启动子流程的时候需要选择一个父流程。</li>
                            <li>实例:SELECT a.WorkID as No, a.Title as Name, a.Starter, a.WorkID As PWorkID, '011'
                                as PFlowNo, a.FK_Node as PNodeID FROM WF_GenerWorkflow a, WF_GenerWorkerlist b WHERE
                                A.WorkID=b.WorkID AND B.FK_Emp='@WebUser.No' AND B.IsPass=0 AND A.FK_Flow='011'
                                AND a.Title Like '%@Key%'</li>
                        </ul>
                    </div>
                    <div name="RB_StartGuideWay_6">
                        <!--<input type="text" id="TB_BySQLMulti1" name="TB_BySQLMulti1" rows="3"  runat="server" style="width:98%; height: 51px"/>-->
                        <textarea id="TB_BySQLMulti1" name="TB_BySQLMulti1" rows="3" runat="server" style="width: 98%;
                            height: 51px" /></textarea>
                        <br />
                        <a href="javascript:ShowHidden('ParasMulti2')">初始化列表参数:</a>
                        <div id="ParasMulti2" style="display: none; color: gray">
                            <ul>
                                <li>比如:SELECT top 15 No,Name ,No as EmpNo,Name as EmpName ,Email FROM WF_Emp </li>
                                <li>或者:SELECT No,Name ,No as EmpNo,Name as EmpName ,Email FROM WF_Emp WHERE ROWID <
                                    15 </li>
                                <li>该数据源必须有No,Name两个列, 其他的列要与开始节点表单字段对应。</li>
                                <li>注意查询的数量，避免太多影响效率。</li>
                            </ul>
                        </div>
                        <!--<input type="text" id="TB_BySQLMulti2" name="TB_BySQLMulti2" rows="3"  runat="server" style="width:98%; height: 51px"/>-->
                        <textarea id="TB_BySQLMulti2" name="TB_BySQLMulti2" rows="3" runat="server" style="width: 98%;
                            height: 51px"></textarea>
                        <br />
                    </div>
                </fieldset>
                <fieldset>
                    <legend>
                        <input id="RB_StartGuideWay_4" type="radio" name="RB_StartGuideWay" value="4" /><label
                            for="RB_StartGuideWay_4">子流程实例列表模式-多条</label>
                    </legend><a href="javascript:ShowHidden('SubFlowParas1')">查询参数:</a>
                    <div id="SubFlowParas1" style="display: none; color: gray">
                        <ul>
                            <li>比如:SELECT No, Name, No as EmpNo,Name as EmpName,Email FROM WF_Emp WHERE No LIKE
                                '%@key%' </li>
                            <li>初始化列表参数，该查询语句必须有No,Name两个列，注意显示数量限制。</li>
                            <li>很多场合下需要用到父子流程，在启动子流程的时候需要选择一个父流程。</li>
                            <li>实例:SELECT a.WorkID as No, a.Title as Name, a.Starter, a.WorkID As PWorkID, '011'
                                as PFlowNo, a.FK_Node as PNodeID FROM WF_GenerWorkflow a, WF_GenerWorkerlist b WHERE
                                A.WorkID=b.WorkID AND B.FK_Emp='@WebUser.No' AND B.IsPass=0 AND A.FK_Flow='011'
                                AND a.Title Like '%@Key%'</li>
                        </ul>
                    </div>
                    <!--<input id="TB_SubFlow1" name="TB_SubFlow1" rows="3" type="text" runat="server" style="width:98%; height: 51px"/>-->
                    <div name="RB_StartGuideWay_4">
                        <textarea id="TB_SubFlow1" name="TB_SubFlow1" rows="3" runat="server" style="width: 98%;
                            height: 51px"></textarea><br />
                        <a href="javascript:ShowHidden('subflow2')">初始化列表参数:</a>
                        <div id="subflow2" style="display: none; color: gray">
                            <ul>
                                <li>比如:SELECT top 15 No,Name ,No as EmpNo,Name as EmpName ,Email FROM WF_Emp </li>
                                <li>或者:SELECT No,Name ,No as EmpNo,Name as EmpName ,Email FROM WF_Emp WHERE ROWID <
                                    15 </li>
                                <li>该数据源必须有No,Name两个列, 其他的列要与开始节点表单字段对应。</li>
                                <li>注意查询的数量，避免太多影响效率。</li>
                            </ul>
                        </div>
                        </font>
                        <!--<input id="TB_SubFlow2" type="text" name="TB_SubFlow2" rows="3"  runat="server" style="width:98%; height: 51px"/>-->
                        <textarea id="TB_SubFlow2" name="TB_SubFlow2" rows="3" runat="server" style="width: 98%;
                            height: 51px"></textarea><br />
                    </div>
                </fieldset>
                <fieldset id="isShow">
                    <legend>
                        <input id="RB_StartGuideWay_90" type="radio" name="RB_StartGuideWay" value="90" /><label
                            for="RB_StartGuideWay_90">开始节点绑定的独立表单列表</label>
                    </legend><font color="gray">
                        <ul>
                            <li>流程启动的时候，系统会把流程引擎绑定的开始节点表单列出来让操作员去选择。 </li>
                            <li>选择一个或者n个表单后，系统就会把参数 Frms 带入到工作处理器里，让工作处理器启用这个表单。 </li>
                            <li>这种工作方式适应的环境是一个流程可以挂接多个表单。 </li>
                        </ul>
                    </font>
                </fieldset>
            </td>
        </tr>
        <tr>
            <!--  <td>
        </td>-->
            <td>
                右侧连接(对按设置的SQL-单条模式有效):
                <br />
                <!--<input tpye='text'    id="TB_GuideLink" name="TB_GuideLink" Width="564px"></input>-->
                <textarea id="TB_GuideLink" name="TB_GuideLink" style="width: 98%; height: 51px"></textarea>
                <br />
                连接标签
                <br />
                <!--<input tpye='text'  class="TextBoxReadonly" id="TB_GuideLab" name="TB_GuideLab"></input>-->
                <textarea class="TextBoxReadonly" id="TB_GuideLab" name="TB_GuideLab" style="width: 98%;
                    height: 51px"></textarea>
            </td>
        </tr>
        <tr>
            <!--   <td>
        </td>-->
            <td>
                <input type="button" id="Btn_Save" runat="server" value="保存" onclick="SaveEn()" />
                <input type="button" id="Button1" runat="server" value="我需要帮助" onclick="Help()" />
                | <span id="dtsbt"><a href="../TestFlow.htm?FK_Flow=flowNo&SID=userId&Lang=CH" target="_blank">
                    运行测试</a></span>
            </td>
        </tr>
    </table>
    </form>
</body>
<script type="text/javascript">
    //动态修改参数
    $("#isShow a").click(function () {
        $(this).attr("href", $(this).attr('href').replace('flowNo', GetQueryString("FK_Flow")));
        $(this).attr("href", $(this).attr('href').replace('userId', userId));
    });
</script>
</html>
